﻿
//依赖于地图容器
var CustomMap = {
    //ModifyMapInit 加载修改状态的地图时，加载此函数
    Map: "",
    CenterPointX: 116.404, //中心轴的X坐标
    CenterPointY: 39.915, //中心轴的Y坐标
    Zoom: 12,    //地图的缩放比例
    MarkerPointX: 116.404, //标记的X坐标
    MarkerPointY: 39.915, //标记的Y坐标
    Init: function () {

        //创建一个坐标
        var a = new BMap.Point(CustomMap.CenterPointX, CustomMap.CenterPointY);
        //中心轴定位
        CustomMap.Map.centerAndZoom(a, CustomMap.Zoom);
        //滚动特效
        CustomMap.Map.enableScrollWheelZoom();
        //添加控件
        CustomMap.Map.addControl(new BMap.NavigationControl());

        //创建标记坐标
        var markPoint = new BMap.Point(CustomMap.MarkerPointX, CustomMap.MarkerPointY);
        //创建备注标记
        var b = new BMap.Marker(markPoint);
        //        b.enableDragging();
        //        b.addEventListener("dragend", function (e) {
        //            CustomMap.MarkerPointX = e.point.lng;
        //            CustomMap.MarkerPointY = e.point.lat;
        //        });
        var c = new BMap.Label("商家位置", {
            offset: new BMap.Size("13", "-2")
        });

        b.setLabel(c);
        var d = new BMap.Icon("/Scripts/Map/img/location.gif", new BMap.Size(14, 23));
        b.setIcon(d);
        CustomMap.Map.clearOverlays();
        CustomMap.Map.addOverlay(b);


    },
    MapShow: function (zoom, centerPointX, centerPointY, markerPointX, markerPointY) {
        var dialogMap = "<div style=\"width: 520px; height: 340px; border: 1px solid gray\" id=\"map_container\"></div>";
        dialogMap = " <div id=\"dialog\" title=\"地址坐标\"><div id=\"map_container\" style=\"width: 520px; height: 340px;\"></div></div> ";
        $("body").append(dialogMap);


        $("#dialog").dialog({
            draggable: true,
            autoOpen: false,
            zIndex: 99999,
            width: 550,
            height: 450,
            buttons: {
                "[ 确 定 ]": function () {

                    $(this).dialog("close");
                }
            }
        });

        $("#dialog").dialog('open');
        $("#dialog").parent().find("button").addClass("ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only");
        CustomMap.Zoom = zoom;
        CustomMap.CenterPointX = centerPointX;
        CustomMap.CenterPointY = centerPointY;
        CustomMap.MarkerPointX = markerPointX;
        CustomMap.MarkerPointY = markerPointY;

        CustomMap.Map = new BMap.Map("map_container");

        CustomMap.Init();
    }


};



